1. Field of the Invention
This invention relates to computer data storage systems, and more particularly to data storage systems including mass storage devices such as hard disk drives.
2. Description of the Related Art
A typical computer system includes one or more hard disk drives (i.e., disk drives) for storing data. The disk drive(s) form non-volatile memory of the computer system; data stored within the disk drive(s) remains persistent even in the absence of applied electrical power. FIG. 1 is a diagram illustrating logical relationships between a file system layer 10, a drive controller layer 12, and disk drive(s) 14 of the typical computer system. Disk drive(s) 14 typically stores data in xe2x80x9cblockxe2x80x9d locations of disk drive(s) 14. Each block location includes one or more contiguous sectors, where a sector is the smallest disk storage unit. File system layer 10 manages the usage of the block locations, and maintains information as to whether each block location is: (i) currently used to store data (i.e., is xe2x80x9cin usexe2x80x9d), or (ii) not currently used to store data (i.e., is xe2x80x9cavailablexe2x80x9d or xe2x80x9cfreexe2x80x9d). File system layer 10 may include, for example, file system software of an operating system.
A typical disk drive includes multiple, disk-shaped platters coated with a layer of a magnetic material, and an equal number of pairs of read/write heads (i.e., xe2x80x9cheadsxe2x80x9d). The heads transform electrical signals to magnetic signals during write operations, and transform magnetic signals to electrical signals during read operations. Each head is attached to an end of an arm, and positioned adjacent to a surface of one of the platters. The arms are connected together such that they move in unison. During operation of the disk drive, the platter is rotated about an axis, and the connected arms are moved to properly position the heads. The platters are divided into multiple tracks arranged as concentric rings. Corresponding tracks on the surfaces of the platters define different cylinders of the disk drive, and each track is divided into sectors.
During a typical write operation, file system layer 10 determines one or more xe2x80x9cfreexe2x80x9d block locations of disk drive(s) 14 where data may be written (i.e., stored), and issues a write command to drive controller layer 12. The write command includes the data and specifies the one or more xe2x80x9cfreexe2x80x9d block locations of disk drive(s) 14 where the write data is to be stored. The specified one or more xe2x80x9cfreexe2x80x9d block locations of disk drive(s) 14 where the write data is to be stored may be translated to drive, cylinder, head, and/or sector information of disk drive(s) 14. Drive controller layer 12 translates the write command according to an interface standard, and conveys the translated write command to disk drive(s) 14. In response to the write command, disk drive(s) 14 stores the data in the xe2x80x9cfreexe2x80x9d block locations specified by the write command. In addition, file system layer 10 updates its block location usage information to reflect that the block locations of disk drive(s) 14 have been transitioned from xe2x80x9cfreexe2x80x9d to xe2x80x9cin usexe2x80x9d.
During a typical read operation to retrieve stored data from disk drive(s) 14, file system layer 10 determines the one or more block locations of disk drive(s) 14 where the desired data is stored, and issues a read command to drive controller layer 12 specifying the one or more block locations. The specified one or more block locations of disk drive(s) 14 where the desired data is stored may be translated to drive, cylinder, head, and/or sector information of disk drive(s) 14. Drive controller layer 12 translates the read command according to the interface standard, and conveys the translated read command to disk drive(s) 14. In response to the read command, disk drive(s) 14 reads the data from the block locations specified by the read command, and provides the data to drive controller layer 12. Drive controller layer 12 in turn provides the read data to file system layer 10.
In order to access a different cylinder of the disk drive, a mechanical movement of the arms must occur. Such mechanical movements require relatively long periods of time. Also, even when the head is at the correct cylinder/head, a rotational delay is incurred for the disk to rotate until the correct location is under the head. As a result, the above describe typical write and read operations create several performance issues for the typical computer system. To minimize the mechanical and rotational delays, it would be desirable for writes to occur to a free block location as close to the current head position as possible. For the file system to attempt to perform writes near the current head position, file system layer 10 may need to know: (i) the internal xe2x80x9cgeometryxe2x80x9d of disk drive(s) 14 (i.e., the number of cylinders, heads, and sectors of disk drive(s) 14), and (ii) the current position of the heads of disk drive(s) 14. Although head position estimation algorithms exist, delays between disk drive(s) 14 and file system layer 10 make it difficult to determine head position accurately. As file system layer 10 cannot accurately predict which xe2x80x9cfreexe2x80x9d block locations are near one or more heads of disk drive(s) 14 at any given time, write operations may not be as efficient as desired. As file systems become even further removed from the disk drives, such as in storage area networks (SANs), the latencies between the file system layer and the drives may increase making drive head location prediction even more difficult. In addition, where disk drive(s) 14 includes multiple disk drives, the burden of tracking the current head position of all the disk drives may present a significant amount of overhead for file system layer 10.
It would thus be desirable to have a computer system wherein decisions as to where data should be stored in a disk drive are made such that write operation efficiencies are improved.
A described storage device controller is configured for coupling to a storage device (e.g., a hard disk drive) having a multiple locations for storing data. The controller is coupled to receive a WRITE ANYWHERE command including write data. Unlike a conventional write command, the WRITE ANYWHERE command does not specify a location of the storage device where the write data is to be stored. The controller responds to the WRITE ANYWHERE command by: (i) selecting one or more unused locations of the storage device, and (ii) writing the write data to the storage device, wherein the writing of the write data includes directing the storage device to store the write data in the one or more unused locations of the storage device. At least a portion of the write data is stored in each of the one or more unused locations. The controller may be coupled to receive the WRITE ANYWHERE command from a host configured to track usage of the locations of the storage device. After writing the write data to the storage device, the controller may report the one or more locations of the storage device where the write data is stored to the host.
The storage device may include one or more surfaces configured to store data. The surfaces may be divided into different regions, forming the multiple locations. The controller may include a memory for storing data indicating unused locations of the storage device, and the controller may select the unused location of the storage device from the data indicating unused locations of the storage device.
In addition to the WRITE ANYWHERE command, the host may issue FREE commands to the controller specifying locations of the storage device which should be identified as unused. In response to a received FREE command, the controller may add information to the memory indicating that the location of the storage device specified by the FREE command is unused.
Several described embodiments of an apparatus (e.g., a computer system) include the above described storage device and the above described controller coupled to the storage device. The storage device may be, for example, a disk drive including a disk-shaped platter having a surface configured to store data. The surface may be divided into multiple regions. The controller may include a memory for storing data indicating unused regions of the surface of the platter. A WRITE ANYWHERE command received by the controller includes write data, but does not specify a region of the surface of the platter where the write data is to be stored. The controller responds to the WRITE ANYWHERE command by: (i) selecting one or more unused regions of the surface of the platter from the data indicating unused regions of the surface of the platter, and (ii) writing the write data to the disk drive, wherein the writing of the write data includes directing the disk drive to store the write data in the one or more selected unused regions of the surface of the platter.
The platter may be rotated about an axis during operation of the disk drive. As is typical, the disk drive may include a read/write head positioned adjacent to the surface of the platter, wherein the read/write head is used to store data within the surface and to retrieve stored data from the surface. The controller may maintain information regarding a current position of the read/write head with respect to the rotating platter (e.g., based upon previous commands issued to the disk drive). Alternately, the disk drive may provide head position information to the controller indicating the current position of the read/write head with respect to the rotating platter. In either situation, the controller may be configured to select the unused region of the surface from the data indicating unused regions of the surface dependent upon the current position of the read/write head with respect to the rotating platter.
As is typical, the surface of the platter may be divided into a multiple tracks arranged as concentric rings, wherein each track is divided into a multiple sectors. The multiple regions of the surface of the platter may include multiple data regions. Each track may include a portion of the data regions. Each data region may include multiple disk blocks, wherein each disk block includes one or more sectors.
In some embodiments, the multiple regions of the surface of the platter also include multiple map regions, wherein each map region includes a disk map corresponding to a different one of the data regions. A given disk map may be located on the same track as the corresponding data region. Each disk map includes information indicating whether each disk block of the corresponding data region is used or unused. The map regions may be located within data regions.
The selected unused regions of the surface specified in the writing of the write data may include one or more unused disk blocks. A data region including one of the unused disk blocks and the corresponding disk map may both be written during the same rotation of the platter. To facilitate the writing of the data region and the corresponding disk map during the same rotation of the platter, each data region may be positioned a fixed offset distance rotationally ahead of the corresponding disk map. The controller may write the data region and the corresponding disk map via back-to-back writes to the disk drive, and wherein the fixed offset distance is selected dependent upon an amount of time required for the controller to issue, and the disk drive to execute, the back-to-back writes to the disk drive.
The memory of the controller may include a map cache for storing copies of a portion of the disk maps stored on the surface of the platter. The controller may use the copies of the disk maps stored in the map cache to select the unused region of the surface of the platter. The map cache may include copies of the disk maps on a track of the surface of the platter adjacent to which the read/write head is currently positioned (i.e., maps on a current track). The map cache may also include copies of disk maps on tracks near the current track.
The memory of the controller may include a non-volatile memory for storing updated versions of a portion of the disk maps stored on the surface of the platter. After writing the write data to the storage device, the controller may update the disk map corresponding to the data region including the unused disk block, and store the updated version of the disk map in the non-volatile memory. At some later time, the controller may write the updated versions of the disk maps stored within the non-volatile memory to the disk drive.
The memory of the controller may include a non-volatile memory for storing disk maps corresponding to all of the data regions on the surface of the platter. After writing the write data to the storage device, the controller may simply update the disk map corresponding to the data region including the unused disk block within the non-volatile memory.
The above described apparatus may include the above described host coupled to the controller. As described above, the host tracks usage of the regions for storing data of the disk drive. For example, the host may include a central processing unit coupled to a memory and configured to execute instructions stored within the memory, and file system software within the memory comprising instructions for tracking usage of the regions for storing data of the disk drive.
One embodiment of a method for writing data to a disk drive includes a drive controller receiving a file system command specifying data to be written to the disk drive but not specifying a location to write the data. The drive controller determines a current head position of the disk drive, and selects a free location of the disk drive to write the specified data depending on the current head position. The drive controller writes the specified data to the selected location. The drive controller updates a map of free locations to indicate that the selected location is no longer free. The drive controller reports to the file system the selected location at which the specified data was written.
The map of free locations may indicate which locations on the disk drive are free for storing data. The selecting of the free location may include the drive controller selecting the free location nearest the current head position of the disk drive with time to write the specified data.
The method may further include the drive controller caching in a cache memory a portion of the map of free locations for locations proximate the current head position. The selecting may include accessing the cache memory according to the current head position to locate the free location nearest the current head position with time to write the specified data.
The map of free locations may be distributed into map portions residing on multiple tracks of the disk drive. Each map portion may correspond to a data region residing on the same track. Each map portion may be offset from the corresponding data region so that the map portion can be written in the same disk rotation as the corresponding data region. The updating may include updating the map portion for the data region in which the selected location is located.
The updating may also include the drive controller updating a portion of the map of free locations in a non-volatile memory. The non-volatile memory may be configured to store portions of the map of free locations. The method may further include writing updated map entries in the non-volatile memory to the disk drive when the disk drive is idle or when the non-volatile memory is full. The map of free locations for the entire disk drive is stored in the non-volatile memory.